package com.example.back.controller;

import com.alibaba.fastjson.JSONObject;
import com.example.back.service.InquiryService;
import com.example.common.support.Result;
import com.example.common.utils.RequestHelp;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @Author wxy
 * @Date 2021/1/13 14:26
 * @Version 1.0
 */
@RestController
@Api(tags = "服务订单")
@RequestMapping("/api/Inquiry")
public class InquiryController {
    @Resource
    private InquiryService inquiryService;

    @ApiOperation(value = "服务订单", notes = "服务订单")
    @PostMapping(value = "/List")
    public Result<Map<String, Object>> List(HttpServletRequest request) {
        JSONObject Jo = RequestHelp.GetFromBodyJson(request);
        String orderno = Jo.getString("orderno");
        int atype = Jo.getIntValue("atype");
        String dname = Jo.getString("dname");
        String cname = Jo.getString("cname");
        int ocstatus = Jo.getIntValue("ocstatus");

        int page = Jo.getIntValue("page");
        int limit = Jo.getIntValue("limit"); 
        return Result.success(inquiryService.List(orderno,atype,dname,cname,ocstatus, page, limit));
    }

    @ApiOperation(value = "对话列表", notes = "对话列表")
    @PostMapping(value = "/ImList")
    public Result<Map<String, Object>> ImList(HttpServletRequest request) {
        JSONObject Jo = RequestHelp.GetFromBodyJson(request);
        String orderno = Jo.getString("orderno");
        
        int page = Jo.getIntValue("page");
        int limit = Jo.getIntValue("limit"); 
        return Result.success(inquiryService.ImList(orderno, page, limit));
    }

    @ApiOperation(value = "病历 非本院首诊", notes = "病历 非本院首诊")
    @PostMapping(value = "/DiagnosisOut")
    public Result<Map<String, Object>> DiagnosisOut(HttpServletRequest request) {
        JSONObject Jo = RequestHelp.GetFromBodyJson(request);
        String orderno = Jo.getString("orderno");
        return Result.success(inquiryService.DiagnosisOut(orderno));
    }

    @ApiOperation(value = "处方列表", notes = "处方列表")
    @PostMapping(value = "/RxOrderList")
    public Result<List<Map<String, Object>>> RxOrderList(HttpServletRequest request) {
        JSONObject Jo = RequestHelp.GetFromBodyJson(request);
        String orderno = Jo.getString("orderno");
        return Result.success(inquiryService.RxOrderList(orderno));
    }

    @ApiOperation(value = "订单评价", notes = "订单评价")
    @PostMapping(value = "/Comment")
    public Result<Map<String, Object>> Comment(HttpServletRequest request) {
        JSONObject Jo = RequestHelp.GetFromBodyJson(request);
        String orderno = Jo.getString("orderno");
        return Result.success(inquiryService.Comment(orderno));
    }

    @ApiOperation(value = "删除订单评价", notes = "删除订单评价")
    @PostMapping(value = "/DelComment")
    public Result<String> DelComment(HttpServletRequest request) {
        JSONObject Jo = RequestHelp.GetFromBodyJson(request);
        String orderno = Jo.getString("orderno");
        return Result.success(inquiryService.DelComment(orderno));
    }
}
